﻿<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <title>图形</title>
    <meta charset="UTF-8">
    <!-- frame所需脚本和样式 -->
    <script src="../../script/lib/jquery-1.11.2.min.js"></script>
    <link rel="stylesheet" href="../../script/bootstrap-3.3.5/css/bootstrap.min.css">    
    <!--代码语法高亮-->
    <link rel="stylesheet" href="../../script/codemirror/codemirror.css">
    <script src="../../script/codemirror/codemirror_merge.js"></script>
    <!-- 加载代码块 -->
    <link rel="stylesheet" href="../css/styles.css">
    <script src="../js/helper.js"></script>
    <script>
        var pageTitle = "初始化图形对象";
        var pageDesc = "初始化图形对象, 并加载一个Geom数据文件";
    </script>
</head>

<body>
    <div id="wrap">
        <div id="graphWrapper" data-type="graph" style="width:100%; height:500px; border:solid 1px #CCC;"></div>
    </div>
</body>
<script type="module">
    import { Graph, Layer, VectorSource, View, BgUtil } from "../../src/index.js";

    // 初始化graph对象
    let graph = new Graph({
        "target": "graphWrapper",
        "layers": [
            new Layer({
                name: "数据层",
                "source": new VectorSource({
                    "fileUrl": "../../demo-data/abcd.json"
                })
            })
        ],
        "view": new View({
            center: [500, 140],   // 初始中心点
            resolution: 1       // 初始分辨率
        })
    });

    // 显示辅助网格
    BgUtil.generateGrid(Object.assign({ "interval": 10, "graph": graph }));

    // 图形渲染
    graph.render();
</script>

</html>